package main

import (
	"ErgodicBorder/border"
	"ErgodicBorder/load"
	"ErgodicBorder/mask"
	"ErgodicBorder/save"
	"ErgodicBorder/sdf"
	"fmt"
	"log"
)

func main() {
	//加载png图片
	length, width, img, err := load.LoadPhoto("./sample/S500.png")
	if err != nil {
		fmt.Println(err)
		return
	}
	//遮罩处理
	masks, err := mask.GetPhotoMask(img, length, width, 0.5)
	if err != nil {
		fmt.Println(err)
		return
	}
	//find border
	borderList := border.FindBorder(masks)
	//generate SDF
	sdfData := sdf.GenerateSDF(width, length, borderList, masks)
	//save
	if err := save.SaveInPNG(length, width, sdfData, "./demo.png"); err != nil {
		log.Println(err)
	}
}
